﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LX.Web.Excel;

namespace S4Store.Domain.TelSaleKpi
{
    public class CarBrandReport : ExportObject
    {

        #region 数据导出
        public override bool? Discriminate(string propertyname)
        {
            if (propertyname == "KHDJLV")
            {
                return this.KHDJLV >= this.Standard.KHDJLV;
            }
            if (propertyname == "H12DHHFLV")
            {
                return this.H12DHHFLV >= this.Standard.H12DHHFLV;
            }
            if (propertyname == "XSKHZHLV")
            {
                return this.XSKHZHLV >= this.Standard.XSKHZHLV;
            }
            if (propertyname == "LDKHXXLULV")
            {
                return this.LDKHXXLULV >= this.Standard.LDKHXXLULV;
            }
            if (propertyname == "XSJD" || propertyname == "XSSJJDC")
            {
                return this.XSSJJDC >=0;
            }
            return null;
        }
        #endregion


        [Export("车型")]
        public string CarBrandName
        {
            get { return CarBrand.Name; }
        }


        public int Year { get; set; }
        public int Month { get; set; }
        public int Day { get; set; }

        public List<CarBrandTelSaleDayData> DayDatas { get; set; }
        public CarBrandTelSaleMonthConfig MonthConfig { get; set; }
        public TelSaleKpiStandard Standard { get; set; }
        public StoreReport StoreReport { get; set; }
        public CarBrand CarBrand { get; set; }
        public CarBrandReport()
        {
            DayDatas = new List<CarBrandTelSaleDayData>();
        }

        /// <summary>
        /// 本月执行天数
        /// </summary>
        public int Days
        {
            get { return DateTime.DaysInMonth(Year, Month); }
        }

        /// <summary>
        /// 时间进度
        /// </summary>
        public decimal RateOfTime
        {
            get { return (decimal)Day * 100 / (decimal)Days; }
        }

        /// <summary>
        /// 厂方广告获取信息数
        /// </summary>
        [Export("厂方广告获取信息数")]
        public int CFGGHQXXS {
            get
            {
                return DayDatas.Sum(t => t.CFGGHQXXS);
            }
        }

        /// <summary>
        /// 自店广告获取信息数
        /// </summary>
        [Export("自店广告获取信息数")]
        public int ZDGGHQXXS
        {
            get
            {
                return DayDatas.Sum(t => t.ZDGGHQXXS);
            }
        }

        /// <summary>
        /// 电话登记表登记客户数
        /// </summary>
        [Export("电话登记表登记客户数")]
        public int DHDJBDJKHS
        {
            get
            {
                return DayDatas.Sum(t => t.DHDJBDJKHS);
            }
        }

        /// <summary>
        /// 12小时电话回复数
        /// </summary>
        [Export("12小时电话回复数")]
        public int H12DHHFS
        {
            get
            {
                return DayDatas.Sum(t => t.H12DHHFS);
            }
        }

        /// <summary>
        /// 线上转来店客户数
        /// </summary>
        [Export("线上转来店客户数")]
        public int XSZLDKHS
        {
            get
            {
                return DayDatas.Sum(t => t.XSZLDKHS);
            }
        }

        /// <summary>
        /// 来店客户信息录入数
        /// </summary>
        [Export("来店客户信息录入数")]
        public int LDKHXXLRS
        {
            get
            {
                return DayDatas.Sum(t => t.LDKHXXLRS);
            }
        }


        /// <summary>
        /// 交车数
        /// </summary>
        [Export("交车数")]
        public int JCS
        {
            get
            {
                return DayDatas.Sum(t => t.JCS);
            }
        }

        /// <summary>
        /// 网站1获取信息数
        /// </summary>
        [Export("网站获取信息数")]
        public int WZ1HQXXS
        {
            get
            {
                return DayDatas.Sum(t => t.WZ1HQXXS);
            }
        }

        /// <summary>
        /// 网站2获取信息数
        /// </summary>
        public int WZ2HQXXS
        {
            get
            {
                return DayDatas.Sum(t => t.WZ2HQXXS);
            }
        }

        /// <summary>
        /// 网站3获取信息数
        /// </summary>
        public int WZ3HQXXS
        {
            get
            {
                return DayDatas.Sum(t => t.WZ3HQXXS);
            }
        }

        /// <summary>
        /// 获取信息总数
        /// </summary>
        [Export("获取信息总数")]
        public int HQXXZS
        {
            get
            {
                return CFGGHQXXS + ZDGGHQXXS + WZ1HQXXS + WZ2HQXXS;
            }
        }

        /// <summary>
        /// 电话客户登记率
        /// </summary>
        [Export("电话客户登记率",Format="{0}%")]
        public decimal KHDJLV
        {
            get
            {
                if (HQXXZS == 0) return 0;
                return DHDJBDJKHS * 100 / HQXXZS;
            }
        }

        /// <summary>
        /// 12小时电话回复率
        /// </summary>
        [Export("12小时电话回复率", Format = "{0}%")]
        public decimal H12DHHFLV
        {
            get
            {
                if (HQXXZS == 0) return 0;
                return H12DHHFS * 100 / HQXXZS;
            }
        }

        /// <summary>
        /// 电话销售目标
        /// </summary>
        [Export("电话销售目标")]
        public int DHXSMB
        {
            get
            {
                return DayDatas.Sum(t => t.DHXSMB);
            }
        }

        /// <summary>
        /// 线上客户转换率
        /// </summary>
        [Export("线上客户转换率", Format = "{0}%")]
        public decimal XSKHZHLV
        {
            get
            {
                if (HQXXZS == 0) return 0;
                return XSZLDKHS * 100 / HQXXZS;
            }
        }

        /// <summary>
        /// 来店客户信息录入率
        /// </summary>
        [Export("来店客户信息录入率", Format = "{0}%")]
        public decimal LDKHXXLULV
        {
            get
            {
                if (XSZLDKHS == 0) return 0;
                return LDKHXXLRS * 100 / XSZLDKHS;
            }
        }

        /// <summary>
        /// 电话销售进度
        /// </summary>
        [Export("电话销售进度", Format = "{0}%")]
        public decimal XSJD
        {
            get
            {
                if (this.MonthConfig.DHXSMB == 0) return RateOfTime;
                return JCS * 100 / MonthConfig.DHXSMB;
            }
        }

        /// <summary>
        /// 销售时间进度差
        /// </summary>
        [Export("销售时间进度差", Format = "{0}%")]
        public decimal XSSJJDC
        {
            get
            {
                return XSJD - RateOfTime;
            }
        }


        /// <summary>
        /// 应时销量
        /// </summary>
        [Export("应时销量")]
        public decimal YSXL
        {
            get
            {
                return MonthConfig.DHXSMB*RateOfTime/100;
            }
        }
    }
}
